Run local Nextjs App in a Cloudflare Tunnel with UntunJS

In development we often want to test out features we are building but can only do so with deployed or staging applications or setting up Ngrok or Cloudflare Tunnels.

UntunJS allows us to get the benefits of Cloudflare tunnels without having to go into the Cloudflare dashboard and set it up.

In this quick lesson we utilize UntunJS to run our local Nextjs application in a Cloudflare Tunnel

Share with a coworker

Transcript

[00:00] The quickest way to get started with Cloudflare tunnels is to use a package from the unjs ecosystem called untun. So here I have my Next.js application running on localhost 3000. In another terminal I'm going to paste the command. All this is saying is we're going to use this untun package, create a tunnel for localhost 3000. I'm going to run it.

[00:24] Now we get this URL. If it was your first time setting it up, you might have to agree to one or more things, but now we have a URL. We can grab it, come to our browser, and we have our localhost application running on a cloudflare tunnel more.